package com.aoxin.service.impl.course.webCourse;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.aoxin.mapper.course.webCourse.SlfClassMapper;
import com.aoxin.mapper.opm.SlfEmployeeMapper;
import com.aoxin.model.course.SlfClass;
import com.aoxin.service.inter.course.webCourse.ClassService;
import com.aoxin.util.EmptyUtil;

@Service
public class ClassServiceImpl implements ClassService {

    @Autowired
    private SlfClassMapper slfClassMapper;
    
    @Autowired
    private SlfEmployeeMapper slfEmployeeMapper;

    @Override
    @Transactional
    public Integer deleteClassById(Integer classId) {
        Integer result = 0;
        if(classId != 0){
            result = slfClassMapper.deleteClassById(classId);
        }
        return result;
    }

    @Override
    @Transactional
    public Integer deleteClass(List<Integer> classIds) {
        Integer result = 0;
        if(classIds != null && classIds.size() > 0){
            result = slfClassMapper.deleteClass(classIds);
        }
        return result;
    }

    @Override
    @Transactional
    public Integer insertClass(SlfClass slfClass) throws IllegalAccessException {
        if(!EmptyUtil.objFieldsIsEmpty(slfClass)){
            this.slfClassMapper.insertClass(slfClass);
        }
        return slfClass.getClassId();
    }

    @Override
    public List<SlfClass> getClasses(Map<String,Object> map) {
        List<SlfClass> slfClasses =  slfClassMapper.getClass(map);
        return slfClasses;
    }

    @Override
    @Transactional
    public Integer updateClass(SlfClass slfClass) throws IllegalAccessException {
        Integer result = 0;
        if(!EmptyUtil.objFieldsIsEmpty(slfClass)){
            result = slfClassMapper.updateClass(slfClass);
        }
        return result;
    }
}
